<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
    <head>
        <base href="<%=basePath%>">
        <meta charset="UTF-8">
        <title>欢迎</title>
    </head>
    <body>
        <div>
            <c:choose>
                <c:when test="${sessionScope.containsKey('userName')}">
                    已登录，可以发表文章。 <a href="user/forwardCreateArticle">发表文章</a>
                    <br />
                </c:when>
                <c:otherwise>
                    还没有登录，不可以发表文章。
                </c:otherwise>
            </c:choose>
            <p>文章列表：</p>
            <table>
                <c:forEach items="${articles}" var="article" varStatus="vs">
                    <tr>
                        <td><c:out value="${vs.index + 1}"/></td>
                        <td><a href="article/show?articleId=${article.id}"><c:out value="${article.title}"/></a></td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </body>
</html>